package com.aaa.member.service.impl;

import com.aaa.member.dao.CommonCustomerDao;
import com.aaa.member.entity.CommonAddress;
import com.aaa.member.entity.CommonCustomer;
import com.aaa.member.service.CommonCustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CommonCustomer)表服务实现类
 *
 * @author makejava
 * @since 2020-11-27 14:58:50
 */
@Service("commonCustomerService")
public class CommonCustomerServiceImpl implements CommonCustomerService {
    @Resource
    private CommonCustomerDao commonCustomerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CommonCustomer queryById(Integer id) {
        return this.commonCustomerDao.queryById(id);
    }

    /**
     * 查询会员常用联系人
     * @param commonCustomer
     * @return
     */
    @Override
    public List<CommonCustomer> queryAllPeople(CommonCustomer commonCustomer) {
        return commonCustomerDao.queryAll(commonCustomer);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CommonCustomer> queryAllByLimit(int offset, int limit) {
        return this.commonCustomerDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param commonCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public CommonCustomer insert(CommonCustomer commonCustomer) {
        this.commonCustomerDao.insert(commonCustomer);
        return commonCustomer;
    }

    /**
     * 修改数据
     *
     * @param commonCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public CommonCustomer update(CommonCustomer commonCustomer) {
        this.commonCustomerDao.update(commonCustomer);
        return this.queryById(commonCustomer.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.commonCustomerDao.deleteById(id) > 0;
    }
}